package com.lagou.mr;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class NumMapper extends Mapper<LongWritable, Text, NumBean, NullWritable> {
    private NumBean outk = new NumBean();

    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, NumBean, NullWritable>.Context context) throws IOException, InterruptedException {
        //按制表符切割
        String line = value.toString();
        String[] datas = line.split("\t");

        //利用自定义排序实现文件中数据的正排
        for (String data : datas) {
            outk.setNum(Integer.parseInt(data));
            context.write(outk, NullWritable.get());
        }
    }
}
